﻿<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%> 
<%@ taglib prefix="stripes"
	uri="http://stripes.sourceforge.net/stripes.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>欢迎使用 ligerUI 权限管理系统</title>
    <link href="../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="../lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <script src="../lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>  
    <link href="../lib/css/common.css" rel="stylesheet" type="text/css" />  
    <script src="../lib/js/common.js" type="text/javascript"></script>    
    <script src="../lib/js/LG.js" type="text/javascript"></script>
    <script src="../lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="../lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
    <script src="../lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
    <script src="../lib/jquery.form.js" type="text/javascript"></script>
    <script src="../lib/json2.js" type="text/javascript"></script>
    <script src="../lib/js/validator.js" type="text/javascript"></script>
    <script src="../lib/js/ligerui.expand.js" type="text/javascript"></script> 
    <script src="../lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>

</head>

<body style="padding-bottom: 31px;">
	<form id="mainform" method="post"></form>
	<script type="text/javascript"> 

        //当前ID
        var currentID = '${actionBean.employee.id}';
        //是否新增状态
        var isAddNew = currentID == "" || currentID == "0";
        //是否查看状态
        var view = '${actionBean.isView}';
        var isView = (view=="true");
        //是否编辑状态
        var isEdit = !isAddNew && !isView;
        //覆盖本页面grid的loading效果
        LG.overrideGridLoading(); 
        //表单底部按钮 
        LG.setFormDefaultBtn(f_cancel,isView ? null : f_save);

        //创建表单结构
        var mainform = $("#mainform");  
        mainform.ligerForm({ 
         inputWidth: 280,
         fields : [{name:"id",type:"hidden"},
                   {display:"姓名",name:"name",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{required:true,maxlength:20},group:"员工基本信息",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"性别",name:"gender",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{required:true,maxlength:10},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"所在部门",name:"departmentid",newline:true,labelWidth:100,width:220,space:30,type:"select",comboboxName:"combodeptname" ,options:{valueFieldID:"departmentid"},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"行政职务",name:"duty",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:25},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"出生日期",name:"birthday",newline:true,labelWidth:100,width:220,space:30,type:"date",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"身份证号",name:"identityCard",newline:false,labelWidth:100,width:220,space:30,type:"text",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"合同起止日期",name:"contractStartDate",newline:true,labelWidth:100,width:220,space:30,type:"date",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"合同终止日期",name:"contractEndDate",newline:false,labelWidth:100,width:220,space:30,type:"date",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"签约时间",name:"signingDate",newline:true,labelWidth:100,width:220,space:30,type:"date",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"合同期限",name:"contractPeriod",newline:false,labelWidth:100,width:220,space:30,type:"text",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"政治面貌",name:"politicalStatus",newline:true,labelWidth:100,width:220,space:30,type:"text",groupicon:"../lib/icons/32X32/communication.gif"},
                   
                   {display:"居住地址",name:"address1",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:60},group:"联系信息",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"邮政编码",name:"zip1",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:10},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"户籍地址",name:"address2",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"邮政编码",name:"zip2",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:10},groupicon:"../lib/icons/32X32/communication.gif"},
                   // {display:"省份",name:"province",newline:true,labelWidth:100,width:60,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   //{display:"城市",name:"city",newline:false,labelWidth:70,width:60,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   //{display:"乡镇",name:"country",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   //{display:"街道",name:"street",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"手机号码",name:"phone",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:24},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"电子邮箱",name:"email",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:10},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"毕业院校",name:"college",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:60},group:"教育信息",groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"所学专业",name:"major",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"毕业时间",name:"graduationDate",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   {display:"学历",name:"career",newline:false,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"}
                   
                  // {display:"专家",name:"expert",newline:true,labelWidth:100,width:220,space:30,type:"checkbox",validate:{maxlength:60},group:"专业技能",groupicon:"../lib/icons/32X32/communication.gif"},
                   //{display:"学术委员会成员",name:"acnumber",newline:false,labelWidth:100,width:220,space:30,type:"checkbox",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"},
                   //{display:"注册师",name:"register",newline:true,labelWidth:100,width:220,space:30,type:"text",validate:{maxlength:15},groupicon:"../lib/icons/32X32/communication.gif"}                 
                   
                   ],
                   prefixName:"employee",
		 toJSON:JSON2.stringify
        });
        //供应商 在弹出grid中选择
        $.ligerui.get("combodeptname").openSelect({
            grid: { 
               columns: [
			              {display: "序号", name: "id", width: 120 },  
			              {display:"部门名称",name:"deptname",width:120},
			              {display:"地址",name:"address",width:180},
			              {display:"联系人",name:"contactname",width:180},
			              {display:"联系电话",name:"telephone",width:180}
               ],
               dataAction: 'server',
               usePager: true,       //服务器分页
               pageSize:20,
               pageParmName:'page.currentPage',
               pagesizeParmName:'page.pagesize',
               url: '../actions/grid/Grid.action?view=searchDepartment', sortName: 'id',checkbox: false
            },
            search:{
		        fields:[
                    {display:"公司名称",name:"deptname",newline:true,type:"text",cssClass:"field"}
                ]
            },  
            valueField:'id',textField:'deptname',top:90
        });
        
		var actionRoot = "../actions/Employee.action";
		if (isEdit) {
			mainform.attr("action", actionRoot + "?editEmployee");
		}
		if (isAddNew) {
			mainform.attr("action", actionRoot + "?newEmployee");
		} else {
			LG.loadForm(mainform, {
				type : '../actions/Employee.action',
				method : 'getEmployees',
				data : {
					id : currentID
				}
			}, f_loaded);
		}

		if (!isView) {
			//验证
			jQuery.metadata.setType("attr", "validate");
			LG.validate(mainform);
		}

		function f_loaded() {
			if (!isView)
				return;
			//查看状态，控制不能编辑
			$("input,select,textarea", mainform).attr("readonly", "readonly");
		}
		function f_save() {
			LG.submitForm(mainform, function(data) {
				var win = parent || window;
				if (data.isError) {
					win.LG.showError('错误:' + data.message);
				} else {
					win.LG.showSuccess('保存成功', function() {
						win.LG
								.closeAndReloadParent(null,
										"BaseManageEmployees");
					});
				}
			});
		}
		function f_cancel() {
			var win = parent || window;
			win.LG.closeCurrentTab(null);
		}
	</script>
	<%@ include file="../layout/_footer.jsp"%>